<?php

namespace app\demo\exception;


use think\exception\Handle;
use think\Response;
use Throwable;

class Http extends Handle
{
    public $HttpStatus = 500;
    /**
     * Render an exception into an HTTP response.
     *
     * @access public
     * @param \think\Request   $request
     * @param Throwable $e
     * @return Response
     */
    public function render($request, Throwable $e): Response
    {
        // 添加自定义异常处理机制
        if (method_exists($e, 'getStatusCode')) {
            $HttpStatus = $e->getStatusCode();
        }else{
            $HttpStatus = $this->HttpStatus;
        }
            return show(config("status.error"), $e->getMessage(), [], $HttpStatus);
    }

}